<template>
	<view class="content">
		<!-- <image src="../../static/logo.png" mode="widthFix" class="logo"></image> -->
		<view class="text-area">
			<text class="title">{{title}} 欢迎登录 {{username}}</text>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in news" :key="index" 
			@tap="openinfo" :data-newsid="item.id">
				<view class="uni-media-list">
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top">{{item.id}}.{{item.title}}</view>
						<view class="uni-media-list-text-bottom uni-ellipsis">{{item.createTime}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- #ifdef APP-PLUS -->
		<view class="footer">
			<text>APP端</text>
		</view>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->
		<view class="footer">
			<text>微信小程序端</text>
		</view>
		<!-- #endif -->
		<!-- #ifdef H5 -->
		<view class="footer">
			<text>H5端</text>
		</view>
		<!-- #endif -->
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username:'',
				access_token:'',
				title: 'Hello, 爱Music App',
				news :[]
			}
		},
		onLoad:function(e){
			console.log("进入index");
			console.log(e);
			this.username=e.username;
			this.access_token=e.access_token;
			console.log(getApp().globalData.service_url);
			uni.request({
				url: getApp().globalData.service_url+"/item/selectAll?access_token="+this.access_token,
				method: 'GET',
				data: {},
				success: res => {
					console.log(res);
					this.news=res.data.data;
				},
				fail: () => {},
				complete: () => {}
			});
		
		},
		methods: {
			openinfo:function(e){
				var newsid=e.currentTarget.dataset.newsid
				uni.navigateTo({
					url: '../info/info?newsid='+newsid+'&access_token='+this.access_token,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	
	.footer{
		position: fixed;
		bottom: 0upx;
	}
</style>
